home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / bccapp.zip / DBASE.H < prev    next >
C/C++ Source or Header  |  1991-09-15  |  2KB  |  95 lines

  1. /*
  2.  *
  3.  * Database manipulation.
  4.  *
  5.  * (C) 1990 Vision Software
  6.  *
  7.  * $Id: dbase.h 1.2001 91/04/25 15:06:49 pcalvin release $
  8.  *
  9.  * Comments:
  10.  *
  11.  * With this class, we may easily save/recall organized (indexed) database
  12.  * information.  ACCESS is used to provide us with record management
  13.  *
  14.  * Bugs:
  15.  *
  16.  * None documented
  17.  *
  18.  */
  19. #if (!defined(__DATABASE__))
  20. #define __DATABASE__
  21.  
  22. #if (!defined(__ACCESS__))
  23. #include <access.h>
  24. #endif
  25.  
  26. #if (!defined(__INDEX__))
  27. #include <index.h>
  28. #endif
  29.  
  30. /*
  31.  *    Index file descriptors.  Used to maintain
  32.  *    information on multiple indexes.
  33.  */
  34. struct ID
  35.     {
  36.     INDEX *pinx;                        // Index object
  37.     SZ sz;                                // Key entry
  38.     CCH cch;                                // Length of key
  39.     };
  40.     
  41. typedef struct ID *PID;
  42. STATIC CONST PID pidNil = Nil;
  43.  
  44. typedef UINT CID;
  45. STATIC CONST CID cidNil = Nil;
  46. STATIC CONST CID cidOpenMax = 10;
  47. STATIC CONST CID cidError = cidOpenMax+1;
  48.  
  49. /*
  50.  *
  51.  *    Although no information is stored by DATABASE proper, this allows us to
  52.  * "TYPE" those structures that are to be accessed.  This will
  53.  * (Hopefully) warn anyone maintaining code that the structure is
  54.  * used for file access.
  55.  *
  56.  */
  57. class DBASE : public INF
  58.     {
  59.     };
  60.  
  61. /*
  62.  *
  63.  * Database.  File access is controlled by ACCESS.  Indexing is used to
  64.  * control access to specific records.
  65.  *
  66.  */
  67. class DATABASE : private ACCESS
  68.     {
  69. public:
  70.     DATABASE(DBASE *pdb,CCH cchRecord,SZ szFileName,BOOL fCreateFile = fFalse);
  71.     ~DATABASE();
  72.     BOOL FSave();
  73.     BOOL FDelete();
  74.     BOOL FFirst();
  75.     BOOL FLast();
  76.     BOOL FNext();
  77.     BOOL FPrevious();
  78.     BOOL FCreate();
  79.     BOOL FMark();
  80.     BOOL FGotoMark();
  81.     BOOL FGotoSz(SZ sz,BOOL fMatchIfClose = fFalse);
  82.     BOOL FGotoRec(REC rec);
  83.     BOOL FIndexTo(CID cid);
  84.     CID CidIndexOn(SZ szFileName,CHAR *pchKey,CCH cchKey);    
  85.     DBASE *PdbQuery();
  86.     SZ SzIndex(CID cid = cidError);
  87.     CCH CchIndex(CID cid = cidError);
  88. private:
  89.     ID rgidActive[cidOpenMax];
  90.     PID pidCurrent;    
  91.     CID cidAvailableMac;
  92.     };
  93.  
  94. #endif    /* !defined(__DATABASE__) */
  95.